import com.ailk.kbi.kbirazor.control.KbrControl;
import com.ailk.kbi.kbirazor.model.KbrModel;

import mx.events.CloseEvent;
import mx.events.FlexEvent;
import mx.managers.PopUpManager;
import mx.controls.Alert;
import mx.events.AdvancedDataGridEvent;
import mx.events.AdvancedDataGridEventReason;
import mx.events.FlexEvent;
import mx.utils.StringUtil;
import mx.controls.TextInput;

[Bindable]
private var kbrModel:KbrModel = KbrModel.getInstance();
private var kbrControl:KbrControl = new KbrControl();

protected function titlewindow2_closeHandler(event:CloseEvent):void
{
	kbrModel.thresholdSetWindowFlag = false;
	PopUpManager.removePopUp(this);	
	
}

protected function init(event:FlexEvent):void
{
	if(kbrModel.kpiIds) {
		kbrControl.getThresholdSetXML();
	}
}

protected function communicationSetGrid_itemEditEndHandler(event:AdvancedDataGridEvent):void
{
	//如果没有更新数据则直接返回  
	if (event.reason == AdvancedDataGridEventReason.CANCELLED){  
		return;  
	}    
	var input:TextInput = TextInput(communicationSetGrid.itemEditorInstance);  
	var newData:String= input.text;  
	
	//如果是数量则验证必须为数字  
	if((event.dataField == "@min" || event.dataField == "@max") && isNaN(Number(StringUtil.trim(newData)))  ){  
		event.preventDefault();  
		input.errorString="数字必须为数字！";  
		return;  
	}  
	
}